FROM golang:1.22.11-alpine3.20 AS build

RUN apk add git \
    && mkdir -p /go/src/github.com/containers \
    && cd /go/src/github.com/containers \
    && git clone --branch release-1.18 https://github.com/containers/skopeo \
    && cd skopeo/ \
    && CGO_ENABLED=0 DISABLE_DOCS=1 go build -ldflags '-extldflags "-static"' -gcflags "" -tags "containers_image_openpgp btrfs_noversion exclude_graphdriver_btrfs " -o bin/skopeo ./cmd/skopeo

FROM alpine:3.20
COPY --from=build /go/src/github.com/containers/skopeo/bin/skopeo /usr/local/bin/skopeo
ENTRYPOINT ["/usr/local/bin/skopeo"]
